package cn.gxufe.reliable.message.api.config;

import cn.gxufe.reliable.message.api.aware.AwareBeanPostProcessor;
import cn.gxufe.reliable.message.api.consumer.ProcessMqMessage;
import cn.gxufe.reliable.message.api.controller.ForProducerMessageController;
import cn.gxufe.reliable.message.api.mq.ByteRMSConsumer;
import cn.gxufe.reliable.message.api.producer.MessageCallBackInterface;
import cn.gxufe.reliable.message.api.service.CompensableMessage;
import cn.gxufe.reliable.message.api.producer.TryServiceProducer;
import cn.gxufe.reliable.message.api.service.impl.CompensableMessageImpl;
import cn.gxufe.reliable.message.api.producer.impl.TryServiceProducerImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yingjie.rong
 **/
@Configuration
public class RMSApiConfigForProducer {

    @Bean
    @ConditionalOnBean(MessageCallBackInterface.class)
    public ForProducerMessageController messageController(){
        return new ForProducerMessageController();
    }

    @Bean
    @ConditionalOnMissingBean(TryServiceProducer.class)
    public TryServiceProducer canConfirmService(){
        return new TryServiceProducerImpl();
    }

    @Bean
    public CompensableMessage compensableMessage(){
        return new CompensableMessageImpl();
    }

    @Bean
    public AwareBeanPostProcessor awareBeanPostProcessor(){
        return new AwareBeanPostProcessor();
    }


}
